package com.yidu.ladder.delivery.controller;
import java.text.ParseException;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.ladder.delivery.domain.BusinessRecsiptVo;
import com.yidu.ladder.delivery.service.BusinessRecsiptService;
import com.yidu.ladder.system.domain.Customer;


/**
 * 业务受理控制器
 * @author lw
 * @since 2020/1/10
 */
@Controller
@RequestMapping("/fetch/")
public class BusinessRecsiptController {
	
	/**
	 * 将业务受理业务层依赖注入
	 */
	@Autowired
	private BusinessRecsiptService businessRecsiptService;

	
	public BusinessRecsiptController() {
		super();
	}

	public BusinessRecsiptController(BusinessRecsiptService businessRecsiptService) {
		super();
		this.businessRecsiptService = businessRecsiptService;
	}

	public BusinessRecsiptService getBusinessRecsiptService() {
		return businessRecsiptService;
	}

	public void setBusinessRecsiptService(BusinessRecsiptService businessRecsiptService) {
		this.businessRecsiptService = businessRecsiptService;
	}
	
	/**
	 * 组合条件查询所有带分页
	 * @param businessRecsiptVo
	 * @return
	 */
	@GetMapping("businessRecsipts")
	@ResponseBody
	public Map<String, Object> findAllBusinessRecsiptWithPage(BusinessRecsiptVo businessRecsiptVo){
		Map<String, Object> result = businessRecsiptService.findAllBusinessRecsiptWithPage(businessRecsiptVo);
		return result;
	}
	
	/**
	 * 添加业务受理和工单
	 * @param param
	 * @return
	 * @throws ParseException
	 */
	@PostMapping("businessRecsipt")
	@ResponseBody
	public Boolean addBusinessRecsipt(@RequestParam Map<String, Object> param) throws ParseException {
		boolean result = businessRecsiptService.addBusinessRecsipt(param);
		return result;
	}
	
	/**
	 * 根据电话号码查询客户
	 * @param customerPhone
	 * @return
	 */
	@GetMapping("customer/{customerPhone}")
	@ResponseBody
	public Customer findCustomerByCustomerPhone(@PathVariable String customerPhone){
		Customer result = businessRecsiptService.findCustomerByCustomerPhone(customerPhone);
		return result;
	}
	
	
	
	
	
	
	
}
